//
//  UploadFntaAppDelegate.m
//  UploadFnta
//
//  Created by Florent Jardin on 30/11/09.
//  Copyright 2009 fnta.me All rights reserved.
//

#import "UploadFntaAppDelegate.h"
#import "Upload.h"
#import "DropView.h"

@implementation UploadFntaAppDelegate

@synthesize window;

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
	NSStatusItem *status = [[[NSStatusBar systemStatusBar] statusItemWithLength:22] retain];
	DropView *view = [[[DropView alloc] init] retain];
	[status setHighlightMode:YES];
	[status setView:view];
	[status setEnabled:YES];
	
}

-(IBAction)uploadFile:(id)sender {
    int result;
    NSArray *fileTypes = [NSArray arrayWithObjects:@"jpg",@"png",@"pdf",nil];
    NSOpenPanel *oPanel = [NSOpenPanel openPanel];
	
    [oPanel setAllowsMultipleSelection:NO];
    result = [oPanel runModalForDirectory:NSHomeDirectory()
									 file:nil
									types:fileTypes];
    if (result == NSOKButton) {
		Upload *engine = [[Upload alloc] init:[oPanel filename]];
		NSString *response = [engine uploadFile:@"http://fnta.me/upload.php" objectName:@"uploadFile"];
		NSLog(@"%@", response);
    }	
}

@end
